# coding=utf-8
# 导入相应的python包
import cv2 
import numpy as np 

import detector
  
single_img_path = "../fabric-defect/麻皮/T03825_00.bmp"
img = detector.cv_read(single_img_path)
detector.cv_show('img', img)
# 使用Canny边缘检测 
edges = cv2.Canny(img,50,200,apertureSize = 3) 
# 进行Hough_line直线检测
lines = cv2.HoughLinesP(edges,1,np.pi/180, 80, 30, 10) 

# 遍历每一条直线
for i in range(len(lines)):
	# (line[0,0], line[0,1])是起点坐标， (line[0,2], line[0,3])是终点坐标， 颜色，线宽
	cv2.line(img,(lines[i, 0, 0],lines[i, 0, 1]), (lines[i, 0, 2],lines[i, 0, 3]), (0,255,0),2) 


detector.cv_show("HoughLinesP", img,block=True)
